Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: feat(gatsby-plugin-fastity): Gatsby v4 DSG & SSR Support #68

Merged
merged 47 commits into from
Nov 5, 2021

Conversation

moonmeister
Copy link
Contributor

@moonmeister moonmeister commented Sep 20, 2021

Description

This PR will implement DSG + SSR support for Gatsby v4.

Documentation

Status: as soon as I can get tests working and run old tests and write new ones this will ship

Related issues

closes #30

@moonmeister moonmeister added the enhancement New feature or request label Sep 20, 2021
@moonmeister moonmeister self-assigned this Sep 20, 2021
@changeset-bot
Copy link

changeset-bot bot commented Sep 20, 2021

🦋 Changeset detected

Latest commit: 74c6f35

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
gatsby-plugin-fastify Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@moonmeister
Copy link
Contributor Author

The issue im #3 above is caused by enabling redirects. Because it tries to register /myroute/ and /myroute and they conflict, probably cause we've told Fastify to ignore trailing slash. Okay, some quick testing shows this redirect really isn't needed. Disabling redirects with Gatsby static solves this. JUST FOUND, a note saying as much, better errors would be nice: https://github.com/fastify/fastify-static#redirect

@moonmeister
Copy link
Contributor Author

@moonmeister
Copy link
Contributor Author

fastify/fastify#3331

@moonmeister
Copy link
Contributor Author

I've been assuming the gatsby render methods handle caching for DSG when I don't know if that's actually true. It better be but I should validate.

… into feat/fastify/gatsby-v4

* 'feat/fastify/gatsby-v4' of github.com:gatsby-uc/plugins:
  Formatting with Prettier
* main:
  Version Packages (#69)
  fix(gatsby-plugin-relative-ci): update dependency @relative-ci/agent to v2 (#76)
  chore(): update dependency lint-staged to v11 (#74)
  chore(gatsby-plugin-github-ribbon): update jest monorepo to v27 (major) (#75)
  chore(gatsby-plugin-github-ribbon): update react monorepo to v17 (major) (#73)
  chore(gatsby-plugin-relative-ci): update non-major updates (#64)
  chore(gatsby-source-packagist): update non-major updates (#65)
  fix(gatsby-plugin-ackee-tracker): update non-major updates (#66)
  chore(gatsby-plugin-github-ribbon): update non-major updates (#63)
  fix: run tets on bot PR
  chore(): update non-major updates (#71)
  chore: upgrade yarn
  chore(repo): action changes (#72)
  chore(gatsby-plugin-fastify): update non-major updates (#62)
  fix(test-site): update non-major updates (#67)
@moonmeister
Copy link
Contributor Author

Prerelease available here: https://www.npmjs.com/package/gatsby-plugin-fastify/v/next

@moonmeister
Copy link
Contributor Author

caching

things to think about. From my discussion with kyle I'm still not sure if Gatsby is caching the HTML/JSON response for DSG routes. I'm guessing the answer is no, but we should confirm. Assuming it's not caching we can implement an in memory cache for these pages. Kyle suggested there would eventually be an API to invalidate routes in caches upon changes in the data layer, we'd use this to burn that source server cache. That cache would need to be able to handle etag/lastUpdate checks and correctly respond. Point is a server side cache could be needed.

* main:
  Version Packages (#86)
  chore(gatsby-plugin-github-ribbon): update non-major dependency versions (#83)
  chore(gatsby-plugin-fastify): update non-major dependency versions (#82)
  chore(gatsby-plugin-fastify): Misc cleanup (#85)
  Update renovate.json
  Version Packages (#81)
  chore(gatsby-plugin-fastify): update non-major updates (#77)
  fix(test-site): update non-major updates (#80)
* main:
  fix: fix yarn lock
  fix: remove learnaa config
  chore: change to changeset publish command from learna. This reducees tooling and supports github releases/changelogs
  Version Packages (#94)
  chore(gatsby-plugin-relative-ci): update dependency @babel/core to ^7.15.8 (#89)
  chore(gatsby-source-packagist): update non-major dependency versions (#90)
  fix(gatsby-plugin-ackee-tracker): update dependency @babel/core to ^7.15.8 (#91)
  fix(test-site): update non-major dependency versions (#93)
  chore(repo): update dependency lint-staged to ^11.2.3 (#92)
  Version Packages (#88)
  rewrite(gatsby-plugin-fastify): move frome callbacks to async/await (#87)
* main:
  Version Packages (#101)
  fix release workflow
  test(gatsby-plugin-fastify): implement testing (#97)
  chore: move renovate to monthly
  feat(gatsby-plugin-fastify): implement better logging (#100)
  Version Packages (#96)
  feat(gatsby-plugin-fastify): unique 404 for API routes (#95)
@cameronbraid
Copy link

I'm looking for a self hosted solution for SSR/DSG and came across this plugin. It seems to address most of my needs, however one thing I need is the ability to proxy unhandled requests to an upstream server.

Currently I am using gatsby 3 without ssr/dsg. I build a docker image using nginx. I use a plugin that generates explicit location directives for each index.html file, static file, and gatsby redirects, plus a final wildcard proxy_pass directive to send the remainder of the traffic upstream.

In order to switch to this plugin, I would need to make the following changes to this plugin:
a) in handleDsgSsr if the request is not for a page then make the handler fall through to a later handler (is this possible in fastly?)
b) in gatsby.ts allowing configuration of FastifyPlugin to be configured before handle404 where I can configure a proxy

@moonmeister moonmeister marked this pull request as ready for review November 5, 2021 22:58
@moonmeister moonmeister merged commit e736248 into main Nov 5, 2021
@moonmeister moonmeister deleted the feat/fastify/gatsby-v4 branch November 5, 2021 23:02
@github-actions github-actions bot mentioned this pull request Nov 5, 2021
moonmeister added a commit that referenced this pull request Nov 9, 2021
* main:
  chore(gatsby-plugin-github-ribbon): update non-major dependency versions (#113)
  chore(gatsby-plugin-relative-ci): update non-major dependency versions to ^7.16.0 (#114)
  chore(gatsby-source-packagist): update non-major dependency versions to ^7.16.0 (#115)
  fix(gatsby-plugin-ackee-tracker): update non-major dependency versions to ^7.16.0 (#116)
  Version Packages (#119)
  WIP: feat(gatsby-plugin-fastity): Gatsby v4 DSG & SSR Support (#68)
  chore: fix benchmarks
  Test/fastify/benchmark (#103)
  fix(test-site): update non-major dependency versions (#111)
  chore(repo): update non-major dependency versions (#110)
  Version Packages (#109)
  chore(several): v4 compt and ackee tracker fix (#108)
  Version Packages (#107)
  fix: not shipping traspiled code on release
jbolda pushed a commit that referenced this pull request Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(gatsby-plugin-fastify): Server Headers
3 participants